<?php include (dirname(__FILE__)."/../include/header.php"); ?>
<?php if(isset($_SESSION['_user']['user_id'])==""){ 
echo "<script>location.href='../user_login.php';</script>";}?>
 
        <div class="container">
          
          <div class="show-gift">
		  <?php  $id=$_GET['id']; $sql="select * from zy_gift where gift_id ='".$id."'";
		 // echo $sql;
		$result = mysql_query($sql);
		while($zy_gift=mysql_fetch_array($result)){
?>
<ul class="breadcrumb">
          <li>
            <li><a href="<?php echo SITE_ROOT;?>/gift">礼品中心</a> <span class="divider">/</span></li>
                <li><a href=""><?php  echo  $zy_gift['gift_name']; ?></a></li>
      </ul>
  <div class="row">
    <div class="span12 bordered-box">
      <div class="show-gift-area">
        <div class="content-header"><h3>礼品 -<?php echo $zy_gift['gift_name'];  ?></h3></div>
        <img src=" <?php echo SITE_ROOT;?><?php echo $zy_gift['image2'];?>">
        <div class="content-header"><h3>礼品描述</h3></div>
        <p><?php echo $zy_gift['description'];?></p>
		 <input name="id1" value="<?php echo $_GET['id'];?>" type="hidden" />
        <h4>所需积分<?php echo $zy_gift['integral']; ?>分 现有积分<?php $sql3="select * from zy_user where user_id = '".$_SESSION['_user']['user_id']."'";$result3=mysql_query($sql3);while($zy_user=mysql_fetch_array($result3)){echo $zy_user['integral'];}?>分 </h4>
		
		           <?php $sql4="select * from zy_user where user_id = '".$_SESSION['_user']['user_id']."'";$result4=mysql_query($sql4);while($zy_user=mysql_fetch_array($result4)){ if($zy_user['integral']>$zy_gift['integral']){ 
				   
				   ?>
					 <input  type="button" name="submit" value="兑换礼品"   onclick="javascript:clickme();"/>
					 <?php }else{?>
					   还差<?php echo ($zy_gift['integral']-$zy_user['integral'])?>分,
                  <a href="<?php echo SITE_ROOT;?>/gift" class="link">返回礼品中心先</a>
					<?php } }?>
				 
              </div>
    </div>
  </div>
  <?php } ?>
</div>
<script type="text/javascript">
function clickme(){
  window.location="gift_checkout.php?id=<?php echo $id; ?>";
  //alert("兑换成功");
}

</script>

<?php include (dirname(__FILE__)."/../include/footer.php"); ?>
